//关于我们
import React, { Component } from 'react';
import {
  View,
  Image,
  StyleSheet,
  Alert,
} from 'react-native';
import {
  Cell,
  Section,
  TableView,
} from 'react-native-tableview-simple';
import * as defaultStyles from '../constants/DefaultStyles';
import NavBar from '../components/NavigatorBar';
import { Actions } from 'react-native-router-flux';
import {CodePush, LocalPackage} from 'react-native-code-push';

export default class AboutUsContainer extends Component {
  constructor(props) {
    super(props);
  }
  _checkUpdate() {
    // let devKey = '';
    // if (defaultStyles.isIOS) {
    //   devKey = 'zlneZzA_8cB4GWT3gDy3s1LyQHEXN162elaOz';
    // }
    // else {
    //   devKey = 'F2lxzjtVUXFu-JODujOl3L56j0A1N162elaOz';
    // }
    // CodePush.checkForUpdate(devKey)
    //   .then((update) => {
    //     if (!update) {
    //       Alert.alert('提示', '应用已是最新版本');
    //     } else {
    //       Alert.alert('提示', '检查到新版本，是否更新', [
    //         {text: '是', onPress:() => {
    //         LocalPackage.install(CodePush.InstallMode.ON_NEXT_RESTART).then()}}, {text: '否', onPress:() => {}}
    //       ]);
    //     }
    //   });
    Alert.alert('提示', '应用已是最新版本');
  }
  render() {
    return (
      <View style={styles.container}>
        <NavBar navBarColor={defaultStyles.LIGHTBLUE} leftImage="angle-left"
                leftClick={() => Actions.pop()} title="关于我们"/>
        <View style={{
            backgroundColor: '#37474F',
            flex: 4,
            alignItems: 'center',
            justifyContent: 'center'
          }}>
          <View style={{
              backgroundColor: '#ffc107',
              width: 80,
              height: 80,
              borderRadius: 10
            }} />
        </View>
        <View style={{flex: 3, backgroundColor: '#EFEFF4'}}>
          <TableView>
            <Section footer="All rights reserved.">
              <Cell title="服务协议" titleTextColor="black" onPress={() => console.log('open Help/FAQ')}
                    accessory={'DisclosureIndicator'} />
              <Cell title="检查更新" titleTextColor="black" onPress={() => this._checkUpdate()}
                    accessory={'DisclosureIndicator'} />
            </Section>
          </TableView>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: defaultStyles.WHITEOFBACKGROUND,
  }
})